import { http } from '@/utils/http'
import type { PreOrder, OrderCreateParams, OrderResult } from '@/types/order'
/**
 * 填写订单-获取预付订单
 * /member/order/pre
 */
export const queryPreOrderInfo = () => {
  return http<PreOrder>({
    method: 'GET',
    url: '/member/order/pre',
  })
}

/**
 * 获取立即支付订单
 * /member/order/pre/now
 */
export const queryPreOrderInfoNow = (data: {
  skuId: string
  count: string
  addressId?: string
}) => {
  return http<PreOrder>({
    method: 'GET',
    url: '/member/order/pre/now',
    data,
  })
}

/**
 * 提交订单接口
 */
export const postOrder = (data: OrderCreateParams) => {
  return http<{ id: string }>({
    method: 'POST',
    url: '/member/order',
    data,
  })
}

/**
 * 获取订单详情
 */
export const queryOrderDetail = (id: string) => {
  return http<OrderResult>({
    method: 'GET',
    url: `/member/order/${id}`,
  })
}
